package com.fc.mall.portal.service.impl;

import com.fc.mall.mapper.UmsIntegrationChangeHistoryMapper;
import com.fc.mall.model.UmsIntegrationChangeHistory;
import com.fc.mall.model.UmsIntegrationChangeHistoryExample;
import com.fc.mall.portal.domain.IntegerationParam;
import com.fc.mall.portal.service.MemberIntegrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Sunny on 2019/6/20.
 */
@Service
public class MemberIntegrationServiceImpl implements MemberIntegrationService {

    @Autowired
    private UmsIntegrationChangeHistoryMapper integrationChangeHistoryMapper;

    @Override
    public List<UmsIntegrationChangeHistory> getMemberIntegrationByMemberId(Long memberId, IntegerationParam param) {
        UmsIntegrationChangeHistoryExample example = new UmsIntegrationChangeHistoryExample();
        UmsIntegrationChangeHistoryExample.Criteria criteria = example.createCriteria().andMemberIdEqualTo(memberId);
        if(null != param.getChangeType() && param.getChangeType().intValue() >= 0)
        {
            criteria.andChangeTypeEqualTo(param.getChangeType());
        }
        example.setOrderByClause("id desc");
        return integrationChangeHistoryMapper.selectByExample(example);
    }
}
